
/**
 * 替换url中的参数值
 * @param url
 * @param paramName 要替换参数
 * @param paramVal 要替换的参数值
 * @returns {string}
 */
function replaceUrlParam(url,paramName,paramVal){
	var tmp = paramName+'=';
	var paramIndex = url.indexOf(tmp);
	var newUrl = '';
	if(paramIndex>=0){
		var end = -1;
		for(var start=paramIndex+tmp.length;start<url.length;start++){
			var char = url.charAt(start);
			if(char=='&'){
				end = start;
				break;
			}
		}
		newUrl =  url.substr(0,paramIndex);
		newUrl = newUrl + paramName+'='+paramVal;
		if(end!=-1){
			newUrl = newUrl + url.substr(end);
		}
	}else {
		var char = url.charAt(url.length);
		if(char!='&'){
			newUrl=url+"&"
		}
		newUrl = newUrl + paramName+'='+paramVal;
	}
	
	return newUrl;
}


/**
 * 删除url中的参数值
 * @param url
 * @param paramName 要删除参数
 * @returns {string}
 */
function delUrlParam(url,paramName){
	var tmp = paramName+'=';
	var paramIndex = url.indexOf(tmp);
	var end = -1;
	for(var start=paramIndex+tmp.length;start<url.length;start++){
		var char = url.charAt(start);
		if(char=='&'){
			end = start;
			break;
		}
	}
	var newUrl =  url.substr(0,paramIndex);
	if(end!=-1){
		newUrl = newUrl + url.substr(end);
	}
	return newUrl;
}